<template>
    <div class="login" v-if="loginUseStore.flag">
        <div class="login-content">
            <div class="login-contentTitle">
                <span>登录</span>
                <i @click="loginUseStore.flag = false">x</i>
            </div>
            <div class="login-contentBottom" v-if="loginUseStore.loginFlag==='login1'">
                <div class="login-item" v-if="!loginUseStore.sqStatus">
                    <div class="login-item-content">
                        <div class="login-itemLeft">
                            <img src="../../assets/images/ewmbackground.png" alt="">
                        </div>
                        <div class="login-itemRight">
                            <h3>扫码登录</h3>
                            <div class="ewm-img">
                                <img :src="loginUseStore.base_64Url">
                                <div class="ewm-sx" v-if="loginUseStore.expire">
                                    <p>二维码已失效</p>
                                    <a href="javascript:;" @click="loginUseStore.refresh">点击刷新</a>
                                </div>
                            </div>
                            <p>使用 <a target="_blank" href="https://music.163.com/#/download">网易云音乐APP</a> 扫码登录</p>
                        </div>
                    </div>
                    <div class="login-item-button">
                        <a href="javascript:;" @click="loginUseStore.loginFlag='login2'">其他登录方式</a>
                    </div>
                </div>
                <div class="login-status" v-else>
                    <img src="../../assets/images/sqz.png" alt="">
                    <h3>扫描成功</h3>
                    <p>请在手机上确认登录</p>
                </div>
            </div>
            <div class="login-contentBottom2" v-else-if="loginUseStore.loginFlag==='login2'">
                <div class="login-contentBottom2-content">
                    <img src="../../assets/images/iphonelogin.png" alt="">
                    <a href="javascript:;">
                        <div>手机号登录/注册</div>
                    </a>
                </div>
                <div class="login-term">
                    <input id="j-official-terms" type="checkbox" v-model="loginUseStore.loginTermFlag">
                    <label for="j-official-terms">同意</label>
                    <a target="_blank" href="https://st.music.163.com/official-terms/service#">《服务条款》</a>
                    <a target="_blank" href="https://st.music.163.com/official-terms/privacy#">《隐私政策》</a>
                    <a target="_blank" href="https://st.music.163.com/official-terms/children#">《儿童隐私政策》</a>
                </div>
                <div class="ewm-login" @click="loginUseStore.getLoginFlag('login1')">
                    <img src="../../assets/images/ewmlogin.png" alt="">
                </div>
            </div>
            <div class="login-contentBottom3" v-else-if="loginUseStore.loginFlag==='login3'">
                <div class="login-contentBottom3-box">
                    <div class="login-iphone-box">
                        <div class="login-iphone-box-input">
                            <el-form>
                                <el-form-item>
                                    <el-input v-model="loginUseStore.loginIphone" type="text" :maxlength="11" placeholder="请输入手机号" />
                                </el-form-item>
                                <el-form-item>
                                    <div class="login-iphone-box-code">
                                        <el-input v-model="loginUseStore.loginCode" type="text" :maxlength="6" placeholder="请输入短信验证码" />
                                        <div class="getCodebtn">
                                            <a href="javascript:;">获取验证码</a>
                                        </div>
                                    </div>
                                </el-form-item>
                                <div class="login-btn">
                                    <a href="javascript:;">登录</a>
                                </div>
                            </el-form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { watch, onMounted } from 'vue';
import loginStore from '@/store/modules/login'
const loginUseStore = loginStore()
onMounted(() => {
    if (loginUseStore.cookie != null) {
        loginUseStore.getLoginStatus(loginUseStore.cookie)
    }
    console.log(loginUseStore.cookie);

})
watch(() => loginUseStore.flag, () => {
    if (loginUseStore.flag) {
        loginUseStore.getRwmLogin()
    }
})
</script>

<style scoped lang="less">
.login {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;

    .login-content {
        position: relative;
        z-index: 9998;
        width: 530px;
        border-radius: 4px;
        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.8);
        border: none;
        background: #fff;

        .login-contentTitle {
            position: relative;
            margin: 0;
            padding: 0 45px 0 18px;
            height: 38px;
            line-height: 38px;
            z-index: 10;
            border-bottom: 1px solid #191919;
            border-radius: 4px 4px 0 0;
            background: #2d2d2d;
            font-weight: bold;
            font-size: 14px;
            color: #fff;

            i {
                position: absolute;
                z-index: 20;
                top: 16px;
                right: 20px;
                width: 10px;
                height: 10px;
                overflow: hidden;
                text-indent: -9999px;
                cursor: pointer;
                background-image: url(../../assets/images/iconback.png);
                background-position: 0 -95px;
            }
        }

        .login-contentBottom {
            margin: auto;
            padding: 0;
            border: 1px solid #d8d8d8;
            border-width: 0 1px 1px;
            border-radius: 0 0 4px 4px;
            background: #fff;
            width: 530px;
            height: 326px;
            background-color: #fff;
            display: flex;
            align-items: center;

            .login-item {
                width: 100%;
                .login-item-content {
                    width: 100%;
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    height: 220px;

                    .login-itemLeft {
                        width: 125px;
                        height: 220px;

                        img {
                            width: 100%;
                            height: 100%;
                        }
                    }

                    .login-itemRight {
                        margin-left: 25px;
                        width: 200px;
                        text-align: center;

                        h3 {
                            font-size: 18px;
                            font-weight: 500;
                            text-align: center;
                        }

                        .ewm-img {
                            position: relative;
                            width: 150px;
                            height: 150px;
                            padding: 4px;
                            margin: 13px auto;

                            img {
                                width: 100%;
                                height: 100%;
                            }

                            .ewm-sx {
                                position: absolute;
                                top: 0;
                                right: 0;
                                bottom: 0;
                                left: 0;
                                background: rgba(255, 255, 255, 0.9);

                                p {
                                    margin: 45px auto 6px;
                                    font-size: 12px;
                                    color: rgba(0, 0, 0, 0.8);
                                    font-weight: 500;
                                }

                                a {
                                    display: block;
                                    margin: 0 auto;
                                    padding-right: 0;
                                    width: 64px;
                                    height: 24px;
                                    line-height: 24px;
                                    text-align: center;
                                    border-radius: 4px;
                                    background: linear-gradient(180deg, #81DD81 0%, #55A055 100%);
                                    border: 1px solid #5BAF5B;
                                    box-shadow: inset 0 -1px 1px 1px rgb(185 230 5.96774194%);
                                    color: #fff;
                                    font-size: 12px;
                                }
                            }
                        }

                        p {
                            font-size: 12px;
                            line-height: 17px;
                            color: rgba(0, 0, 0, 0.4);

                            a {
                                color: #0c73c2;
                            }
                        }
                    }
                }
                .login-item-button{
                    a{
                        display: block;
                        width: 118px;
                        height: 28px;
                        margin: 20px auto 0;
                        padding-right: 0;
                        font-size: 12px;
                        border: 1px solid #979797;
                        border-radius: 15px;
                        line-height: 28px;
                        text-align: center;
                        color: rgba(0, 0, 0, 0.8);
                    }
                }

            }

            .login-status {
                display: flex;
                flex-direction: column;
                align-items: center;
                width: 100%;
                height: 100%;
                padding-top: 40px;

                img {
                    width: 140px;
                    height: 140px;
                }

                h3 {
                    margin-top: 12px;
                    font-size: 18px;
                    font-weight: 450;
                    line-height: 24px;
                    color: rgba(0, 0, 0, 0.8);
                }

                p {
                    margin-top: 4px;
                    font-size: 14px;
                    color: #333;
                }
            }
        }
        .login-contentBottom2 {
            position: relative;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            width: 530px;
            height: 326px;
            background-color: #fff;
            .ewm-login{
                display: block;
                width: 52px;
                height: 52px;
                position: absolute;
                bottom: 0;
                right: 0;
                z-index: 9999;
                img{
                    width: 100%;
                    height: 100%;
                }
            }
            .login-contentBottom2-content{
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
                width: 224px;
                padding: 0 35px 3px 40px;
                height: 220px;
                img{
                    width: 224px;
                    height: 120px;
                }
                a{
                    margin-top: 35px;
                    color: #fff;
                    width: 180px;
                    background-image: url(../../assets/images/button2.png);
                    background-position: right -428px;
                    padding: 0 5px 0 0;
                    display: flex;
                    height: 31px;
                    font-size: 12px;
                    div{
                        width: 184px;
                        background-image: url(../../assets/images/button2.png);
                        background-position: 0 -387px;
                        padding: 0 15px 0 20px;
                        height: 100%;
                        line-height: 31px;
                        text-align: center;
                    }
                }
            }
            .login-term{
                margin-left: 40px;
                margin-top: 30px;
                font-family: NotoSansHans-Regular;
                font-size: 10px;
                color: rgba(0, 0, 0, 0.4);
                line-height: 15px;
                display: flex;
                align-items: center;
                a{
                    color: #507DAF;
                }
            }
        }
        .login-contentBottom3{
            display: flex;
            justify-content: center;
            flex-direction: column;
            margin: auto;
            padding: 0;
            border: 1px solid #d8d8d8;
            border-width: 0 1px 1px;
            border-radius: 0 0 4px 4px;
            background: #fff;
            .login-contentBottom3-box{
                width: 420px;
                min-height: 280px;
                padding-top: 0px;
                padding-bottom: 0px;
                z-index: 9;
                height: 262px;
                margin: 0 auto;
                padding: 0 0 43px;
                box-sizing: content-box;
                .login-iphone-box{
                    width: 100%;
                    height: 100%;
                    border: medium;
                    background: none;
                    box-sizing: border-box;
                    width: 420px;
                    padding-top: 80px;
                    padding-bottom: 18px;
                    .login-iphone-box-input{
                       padding: 0 50px;
                       .login-iphone-box-code{
                        display: flex;
                            input{
                                width: 193px;
                                height: 36px;
                                border-radius: 20px;
                                border: 1px solid rgba(0,0,0,.1);
                                box-sizing: border-box;
                                outline: none;
                                padding-left: 30px;
                            }
                            .getCodebtn{
                                margin-left: 8px;
                                a{
                                    background: #ff3a3a;
                                    border-radius: 20px;
                                    display: block;
                                    width: 119px;
                                    height: 36px;
                                    line-height: 36px;
                                    font-size: 14px;
                                    text-align: center;
                                    color: #fff;
                                }
                            }
                       }
                       .login-btn{
                        margin-top: 24px;
                        margin-bottom: 12px;
                        a{
                            display: block;
                            width: 100%;
                            text-align: center;
                            background: #ff3a3a;
                            border-radius: 20px;
                            line-height: 36px;
                            height: 36px;
                            font-size: 14px;
                            color: #fff;
                        }
                       }
                    }
                }
            }
        }
    }
}</style>